home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Visual Basic Source Code
/
Visual Basic Source Code.iso
/
vbsource
/
hugstr
/
hugearr.h
< prev
next >
Wrap
C/C++ Source or Header
|
1992-09-10
|
4KB
|
102 lines
/* Include file for HUGEARR.DLL modules. */
#ifndef _HUGEARR_H
#define _HUGEARR_H
#include "sjslib.h"
/* Possible return values for huge array functions. */
#define HA_OK 0
#define HA_OUTOFMEMORY -1
#define HA_TOOMANYARRAYS -2
#define HA_SUBSCRIPT -4
#define HA_BADARRAY -5
#define HA_FILEOPENERROR -7
#define HA_FILEWRITEERROR -8
#define HA_FILEREADERROR -9
/* VBG: Global Const HA_OK = 0 */
/* VBG: Global Const HA_OUTOFMEMORY = -1 */
/* VBG: Global Const HA_TOOMANYARRAYS = -2 */
/* VBG: Global Const HA_SUBSCRIPT = -4 */
/* VBG: Global Const HA_BADARRAY = -5 */
/* VBG: Global Const HA_FILEOPENERROR = -7 */
/* VBG: Global Const HA_FILEWRITEERROR = -8 */
/* VBG: Global Const HA_FILEREADERROR = -9 */
/* Structure describing each individual huge array. */
typedef struct HugeDesc
{
HANDLE handle; /* handle to global memory array */
int recsize; /* record size of array */
long ubound; /* upper bound of array */
int perseg; /* #elements per segment */
} HUGEDESC;
typedef HUGEDESC *PHUGEDESC; /* Make type for pointer to huge array description structure. */
typedef double currency; /* currency and double are the same size and will be treated the same */
/* VBG: Type HugeDesc */
/* VBG: handle As Integer */
/* VBG: recsise As Integer */
/* VBG: ubound As Long */
/* VBG: perseg As Integer */
/* VBG: End Type */
extern HANDLE hLocalMem;
extern int NumArrays;
extern int FAR PASCAL VBHugeDim(int recsize, long ubound);
extern int FAR PASCAL VBHugeRedim(int hArray, long ubound);
extern int FAR PASCAL VBHugeGet(int hArray, long element, LPBYTE buffer);
extern int FAR PASCAL VBHugeGetNum(int hArray, long element, int nelem, LPBYTE buffer);
extern int FAR PASCAL VBHugeSet(int hArray, long element, LPBYTE buffer);
extern int FAR PASCAL VBHugeSetNum(int hArray, long element, int nelem, LPBYTE buffer);
extern int FAR PASCAL VBHugeErase(int hArray);
extern int FAR PASCAL VBHugeNumArrays(VOID);
extern long FAR PASCAL VBHugeUbound(int hArray);
extern int FAR PASCAL VBHugeGetInt(int hArray, long element);
extern long FAR PASCAL VBHugeGetLong(int hArray, long element);
extern float FAR PASCAL VBHugeGetSingle(int hArray, long element);
extern double FAR PASCAL VBHugeGetDouble(int hArray, long element);
extern currency FAR PASCAL VBHugeGetCurrency(int hArray, long element);
extern long FAR PASCAL VBHugeSave(int hArray, long nelements, int OutLen, LPSTR FileSpec);
extern long FAR PASCAL VBHugeLoad(int hArray, int InLen, LPSTR FileSpec);
extern HPBYTE FAR PASCAL VBHugeStrCat(HPBYTE hpPtr, LPBYTE lpBuffer);
extern HPBYTE FAR PASCAL VBHugeStrEnd(HANDLE hMem);
extern HPBYTE FAR PASCAL VBHugeLock(HANDLE hMem);
/* Macro to calculate byte offset of an array element given its number, the size of each element,
and the number of elements per segment. */
#define HugeElementOffset(ELEMNO, PERSEG, RECSIZE) \
(ELEMNO) / (long) (PERSEG) * 0x10000L \
+ (ELEMNO) % (long) (PERSEG) * (long) (RECSIZE)
/* Macro to decrement the array handle (since VB users think handles begin with 1), then check
if it is within the valid range. */
#define DecCheckHandle(HARRAY) \
/* VB users think hArray begins at 1 */ \
if (--(HARRAY) < 0 || (HARRAY) >= NumArrays) \
/* illegal array handle */ \
return HA_BADARRAY;
/* Macro to return error if specified array has not yet been allocated. */
#define CheckNotAllocYet(PARRAY) \
if ((PARRAY) -> handle == NULL) \
{ \
/* array hasn't been allocated */ \
LocalUnlock(hLocalMem); \
return HA_BADARRAY; \
}
/* Macro to return error if specified array element is out of bounds. */
#define CheckSubscript(PARRAY, ELEMENT, MAX) \
if ((PARRAY)->ubound < (MAX) || (ELEMENT) < 0) \
{ \
/* subscript out of range */ \
LocalUnlock(hLocalMem); \
return HA_SUBSCRIPT; \
}
#endif